/**
 * 节点默认数据
 * @type {*[]}
 */
const defaultFlow = {
  isConnect: false,//是否连接
  complete: false,//数据配置状态
  select: false,//是否被选中
  choose: false,//连线标记状态
  isOver: false,//鼠标是否悬浮
  active: false,// 获取当前选择节点数据
  check: null// 节点检查状态 是否配置完成
}

/**
 * SQL输入 配置项数据结构
 * @type {{dataType: string, name: string, dataSource: string, sql: string}}
 */
const sqlOption = {
  name: 'SQL输入',//节点名称
  dataSourceId: '',//数据源
  tableName: '',
  sql: ''//sql语句
}

/**
 * ES输入 配置项数据结构
 * @type {{condition: string, field: string, dataType: string, name: string, aggType: string, dataSource: string}}
 */
const esOption = {
  name: 'ES输入',//节点名称
  dataSourceId: '',//数据源
  sql: ''
  /*
  * sql: {
  *   indexPrefix: '',
  *   limit: 10,
  *   group: [], 统计字段，时间字段，指标字段
  *   where: {
  *     chd: [], 条件
  *     operate: 'AND'
  *  }
  * }JSON格式
  * */
}

/**
 * API接口输入 配置项数据结构
 * @type {{dataType: string, name: string, dataSource: string, sql: string}}
 */
const apiOption = {
  name: 'API接口输入',//节点名称
  method: 'GET',//请求方式
  url: '',//url
  query: 'params',
  queryList: [],//参数列表
  path: '',//选择解析字段全路径，字符串逗号隔开
  header: [],//请求头列表
  body: '',
  param: '',
  authorization: ''
}

/**
 * 字段配置 配置项数据结构
 * @type {{common: {isCheck: boolean, fieldName: string, describe: string, fieldType: string}[], name: string}}
 */
const fieldConfig = {
  name: '字段配置',//节点名称
  dataList: [
    // {
    //   fieldName: '',//字段名称
    //   fieldType: '',//字段类型
    //   describe: '',//描述
    //   isCheck: false//选中状态
    // }
  ]
}

const rowToColumnOption = {
  name: '行列转换',//节点名称
  group: '',
  field: '',
  value: '',
}

/**
 * 组件面板
 * @type {*[]}
 */
const componentData = [
  {
    label: '输入组件',
    type: 'Input',
    children: [
      {
        id: '',
        lastId: '',
        nextId: '',
        label: 'SQL输入',
        icon: 'icon-biaoshuru1',
        type: 'MysqlTableInput',
        componentType: 'Input',
        anchors: ['Right'], //节点端点
        position: { left: '', top: '' },
        option: sqlOption,
        ...defaultFlow
      },
      {
        id: '',
        lastId: '',
        nextId: '',
        label: 'ES输入',
        icon: 'icon-biaoshuru1',
        type: 'ESTableInput',
        componentType: 'Input',
        anchors: ['Right'], //节点端点
        position: { left: '', top: '' },
        option: esOption,
        ...defaultFlow
      },
      {
        id: '',
        lastId: '',
        nextId: '',
        label: 'API接口输入',
        icon: 'icon-biaoshuru1',
        type: 'APIInput',
        datasourceType: 'API',
        componentType: 'Input',
        anchors: ['Right'], //节点端点
        position: { left: '', top: '' },
        option: apiOption,
        ...defaultFlow
      }
    ]
  },
  {
    label: '数据处理',
    type: 'OutInput',
    children: [
      // {
      //   id: '',
      //   label: '行列转换',
      //   icon: 'icon-field-config',
      //   type: 'RowToCellConfig',
      //   componentType: 'OutInput',
      //   anchors: ['Left', 'Right'], //节点端点
      //   position: { left: '', top: '' },
      //   option: rowToColumnOption,
      //   ...defaultFlow
      // },
      {
        id: '',
        lastId: '',
        nextId: '',
        label: '字段配置',
        icon: 'icon-field-config',
        type: 'FieldConfig',
        componentType: 'OutInput',
        anchors: ['Left'], //节点端点
        position: { left: '', top: '' },
        option: fieldConfig,
        ...defaultFlow
      }
    ]
  }

]

/**
 * 流程图锚点 起点配置
 * @type {{
 * paintStyle: {strokeWidth: number, outlineStroke: string, fill: string, radius: number},
 * endpoint: string,
 * connector: *[],
 * connectorHoverStyle: {strokeWidth: number, stroke: string},
 * isSource: boolean,
 * connectorStyle: {strokeWidth: number, dashstyle: string, stroke: string}}}
 */
const startCommon = {
  endpoint: 'Dot',//连接点类型 Dot: 圆 Rectangle: 矩形 Triangle: 三角形 Image: 图片 Blank: 空
  paintStyle: {
    stroke: 'transparent',//颜色
    fill: 'transparent',//填充色
    // outlineStroke: 'none',//边框颜色
    strokeWidth: 10,//边线宽度
    radius: 10,//圆设置倒角
    width: 32,
    height: 32
  },//连接点样式
  isSource: true,
  connector: ['Flowchart', { stub: [10, 20], gap: 10, cornerRadius: 5 }],
  connectorStyle: {
    stroke: '#036EFF',
    strokeWidth: 1,
    dashstyle: '2'//虚线间距
  },//连接线的样式，起点可用
  connectorHoverStyle: {
    stroke: '#de7d00',
    strokeWidth: 3
  }
  // maxConnections: -1, //端点连线数量限制  -1则不限制
}

/**
 * 流程图锚点 终点配置
 * @type {{
 * isTarget: boolean,
 * paintStyle: {strokeWidth: number, width: number, fill: string, stroke: string, height: number},
 * endpoint: string,
 * connector: *[]}}
 */
const endCommon = {
  connector: ['Flowchart', { stub: [10, 20], gap: 10, cornerRadius: 5 }],
  endpoint: 'Rectangle',//连接点类型 Dot: 圆 Rectangle: 矩形 Triangle: 三角形 Image: 图片 Blank: 空
  paintStyle: {
    stroke: 'transparent',//颜色
    fill: 'transparent',
    strokeWidth: 1,//边线宽度
    width: 12,//矩形设置宽度
    height: 12
  },//连接点样式
  isTarget: true
}

export {
  componentData,
  // nodeConfig,
  sqlOption,
  esOption,
  fieldConfig,
  startCommon,
  endCommon
}
